<!DOCTYPE html>
<html>
<head>
<title>编辑管理员</title>
[#include "/WEB-INF/admin/include/common.html"]
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>编辑管理员</h5>
            </div>
           <form id="inputForm" action="update" method="post">
           		<input type="hidden" name="id" value="${admin.id}">
	            <div class="ibox-content">
	                <div class="form-horizontal clearfix">
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">用户名：</label>
	                        <div class="col-sm-3">
	                            <input placeholder="用户名" class="form-control" type="text" name="username" value="${admin.username}">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">密码：</label>
	                        <div class="col-sm-3">
	                            <input placeholder="密码" id="password" class="form-control" type="password" name="password" autocomplete="off">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">确认密码：</label>
	                        <div class="col-sm-3">
	                            <input placeholder="确认密码" class="form-control" type="password" name="rePassword" autocomplete="off">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">角色：</label>
	                        <div class="col-sm-8">
	                        	 <div class="checkbox">
		                           	[#list roles as role]
		                           		<label class="m-r">
											<input class="checkbox" type="checkbox" name="roleIds" value="${role.id}" [#if admin.roleIds.contains(role.id)]checked[/#if]/>${role.name} 
										</label>
									[/#list]
								</div>
	                        </div>
	                    </div>
	                     <div class="form-group">
	                        <label class="col-sm-3 control-label">姓名：</label>
	                        <div class="col-sm-3">
	                            <input placeholder="姓名" class="form-control" type="text" name="name" value="${admin.name}">
	                        </div>
	                    </div>
	                    <div class="form-group">
	                        <label class="col-sm-3 control-label">设置：</label>
	                        <div class="col-sm-3">
	                            <div class="checkbox">
	                               <label class="m-r"><input type="checkbox" name="isEnabled" value="true" [#if admin.isEnabled]checked[/#if]/>启用</label>
	                            </div>
	                        </div>
	                    </div>
	                </div>
	            </div>
	            <div class="modal-footer col-sm-3 col-sm-offset-2">
	                <button type="submit" class="btn btn-w-m btn-primary">确定</button>
	                <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
	            </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
	
	// 表单验证
	$inputForm.validate({
		rules: {
			username: {
				required: true,
				pattern: /^[0-9a-zA-Z_\u4e00-\u9fa5]+$/,
				minlength: 2,
				remote: {
					url: "checkUsername",
					cache: false
				}
			},
			password: {
				required: true,
				minlength: 4
			},
			rePassword: {
				required: true,
				equalTo: "#password"
			},
			roleIds: "required",
			isEnabled: "required"
		},
		messages: {
			username: {
				pattern: "非法字符",
				remote: "已存在"
			}
		}
	});

});
</script>